﻿using System.Data.Entity;
using Dm.Domain.Entities.Configurations;


namespace Dm.Domain.Entities
{
    public class BaseContext : DbContext, Dm.Domain.Entities.IBaseContext
    {

        public DbSet<Student> Students { get; set; }
        public DbSet<ContactNumber> ContactNumbers { get; set; }
        public DbSet<Curriculum> Curriculums { get; set; }
        public DbSet<Employee> Employees { get; set; }
        public DbSet<User> Users { get; set; }

        public BaseContext() : base("ARPAMIS") { }

        public virtual IDbSet<T> DbSet<T>() where T : class
        {
            return Set<T>();
        }

        public virtual void Commit()
        {
            base.SaveChanges();
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add<Student>(new StudentConfiguration());
            modelBuilder.Configurations.Add<Employee>(new EmployeeConfiguration());
            modelBuilder.Configurations.Add<KeyAutoGenerator>(new KeyAutoGeneratorConfiguration());
            base.OnModelCreating(modelBuilder);
        }
    }
}
